unit FechaCupom;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Mask;

type
  TFormFechaCupom = class(TForm)
    GBValor: TGroupBox;
    RB_DescontoValor: TRadioButton;
    RB_DescontoPercentual: TRadioButton;
    MaskEdit1: TMaskEdit;
    GBTIpo: TGroupBox;
    RB_Desconto: TRadioButton;
    RB_Acrescimo: TRadioButton;
    Label5: TLabel;
    MaskEdit2: TMaskEdit;
    Label3: TLabel;
    ComboBox1: TComboBox;
    Label1: TLabel;
    Memo1: TMemo;
    BitBtn1: TBitBtn;
    procedure FormShow(Sender: TObject);
    procedure RB_DescontoPercentualClick(Sender: TObject);
    procedure RB_DescontoValorClick(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormFechaCupom: TFormFechaCupom;

implementation

uses funcoesapoio, principal;
{$R *.dfm}

procedure TFormFechaCupom.FormShow(Sender: TObject);
var i:integer;
begin
        CapturaDadosProgamadosECF(2); // Captura Meios de Pagamento
        for i:=1 to 20 do begin
                if not (MeiosPagamento[i].Legenda='') then Combobox1.Items.ADD(MeiosPagamento[i].Legenda);
        end;
        try
                ComboBox1.Text:=MeiosPagamento[1].Legenda;
        except
        end;
        Memo1.Text:=Chr(16)+'E'+'Volte Sempre'+Chr(13)+chr(10)+Chr(16)+'B'+'Obrigado pela preferencia!';

        if FormFechaCupom.Height=386 then begin
                GbValor.Visible:=True; GBTipo.Visible:=True;
                Label5.Visible:=true; maskedit2.visible:=true;
                Label1.top:=176;memo1.top:=191;
        end
        else begin
                GbValor.Visible:=False; GBTipo.Visible:=False;
                Label5.Visible:=false; maskedit2.visible:=False;
                Label1.top:=54; memo1.top:=68;
        end;
        Refresh;

end;

procedure TFormFechaCupom.RB_DescontoPercentualClick(Sender: TObject);
begin
        MaskEdit1.MaxLength:=4;
        MaskEdit1.EditMask:='9999';
        MaskEdit1.Text:='1000';
end;

procedure TFormFechaCupom.RB_DescontoValorClick(Sender: TObject);
begin
        MaskEdit1.MaxLength:=9;
        MaskEdit1.EditMask:='999999999999,99';
        MaskEdit1.Text:='000000000001,00';

end;

procedure TFormFechaCupom.BitBtn1Click(Sender: TObject);
begin
        FormPrincipal.DescontoItem:=MaskEdit1.Text;
        if Rb_DescontoValor.checked then FormPrincipal.TipoDescontoItem:='$'
        else FormPrincipal.TipoDescontoItem:='%';
        if Rb_Desconto.checked then FormPrincipal.TipoDescontoAcrescimo:='D'
        else FormPrincipal.TipoDescontoAcrescimo:='A';

        FormPrincipal.ValorInicioDia:=MaskEdit2.Text;
        FormPrincipal.PagtoInicioDia:=ComboBox1.Text;
        FormPrincipal.TextoPagamento:=Memo1.Text;

end;

end.
